/**
 * Created by Administrator on 2015/12/24.
 */
__.BasicModule.register("select", "2.0", ["lang", "dom", "selector", "event", "cookie", "widget"], function() {
    var c;
    __.widget.Select = function(id, config) {
        this._initCfg(config);
        this.id = id;
        this.listDisplaying = false;
        this.values = {};
        this.value = this._config.defaultValue;
        this.lastActiveItem = null ;
        if (!config.name)
            this._config.name = id + "_select";
        this._createEls();
        this._initEls();
        this._addEvents()
    }
    ;
    __.inherits(__.widget.Select, __.widget.Base);
    c = __.widget.Select;
    c.prototype._cfg = {
        txt: {
            wrongValue: "the value to be set is wrong"
        },
        cls: {
            container: "du-select-ctn",
            icon: "du-select-icon",
            value: "du-select-value",
            list: "du-select-list",
            item: "du-select-item",
            active: "du-select-active",
            input: "du-select-input"
        },
        status: {},
        defInstCfg: {
            width: 45,
            height: 20,
            lineHeight: 13,
            borderColor: "#d0cece",
            bgColor: "#fff",
            items: {
                1: "item 1",
                2: "item 2"
            },
            zIndex: 100,
            defaultValue: 1,
            ctnZindex: 1,
            fontsize: 13,
            bgSrc: "http://mat1.gtimg.com/finance/stock/qq_panel/qq_bg2.gif",
            bgNormal: "-33px -64px",
            bgActive: "-63px 0",
            onChange: function() {}
        }
    };
    c.prototype._error = function(a) {
        throw Error("du-select: " + a);
    }
    ;
    c.prototype._initCfg = function(a) {
        var b, d = 0;
        a = a || {};
        b = this._config = __.lang.clone(this._cfg.defInstCfg);
        __.each(a, function(e, f) {
            b[f] = e
        }, true);
        if (__.lang.isUndefined(a.width)) {
            __.each(a.items, function(e) {
                e = String(e);
                if (e.length > d)
                    d = e.length
            }, true);
            b.width = d * (b.fontsize + 1) + 18
        }
    }
    ;
    c.prototype._initEls = function() {
        var a = __.dom.f(this.id)
            , b = this._cfg.cls;
        this.els = {
            ctn: a,
            innerCtn: __.dom.f("." + b.container, a),
            value: __.dom.f("." + b.value, a),
            icon: __.dom.f("." + b.icon, a),
            list: __.dom.f("." + b.list, a),
            input: __.dom.f("." +
                b.input, a)
        }
    }
    ;
    c.prototype._addEvents = function() {
        var a = __.event.bind
            , b = this.els;
        a = [a(this._hlMouseOver, this), a(this._hlMouseOut, this), a(this._hlClick, this)];
        __.event.on(b.ctn, "mouseover", a[0]);
        __.event.on(b.ctn, "mouseout", a[1]);
        __.event.on(__.doc, "click", a[2]);
        this._fns = a
    }
    ;
    c.prototype._hlMouseOut = function() {
        this.els.icon.style.backgroundPosition = this._config.bgNormal
    }
    ;
    c.prototype._hlMouseOver = function(a) {
        a = a.target || a.srcElement;
        var b = this.els;
        if (a === b.value || a === b.icon || a === b.value.parentNode)
            b.icon.style.backgroundPosition =
                this._config.bgActive;
        else
            for (; a !== this.els.ctn; ) {
                if (__.dom.hasClass(a, this._cfg.cls.item)) {
                    this.setActive(a);
                    break
                }
                a = a.parentNode
            }
    }
    ;
    c.prototype._hlClick = function(a) {
        a = a.target || a.srcElement;
        var b = this.els;
        if (!this.listDisplaying && (a === b.value || a === b.icon || a === b.icon.parentNode))
            this.show();
        else {
            if (__.dom.contains(b.ctn, a))
                for (; a && a !== this.els.ctn; ) {
                    if (__.dom.hasClass(a, this._cfg.cls.item)) {
                        this.set(__.lang.stripTags(a.innerHTML), true);
                        break
                    }
                    a = a.parentNode
                }
            this.hide()
        }
    }
    ;
    c.prototype.setActive = function(a) {
        this.clearActive();
        a.style.background = "#428fdc";
        a.style.color = "#fff";
        this.lastActiveItem = a
    }
    ;
    c.prototype.clearActive = function() {
        if (this.lastActiveItem) {
            this.lastActiveItem.style.background = "#fff";
            this.lastActiveItem.style.color = "#000";
            this.lastActiveItem = null
        }
    }
    ;
    c.prototype.toggle = function() {
        this.listDisplaying ? this.hide() : this.show()
    }
    ;
    c.prototype.show = function() {
        var a = this.els;
        if (!this.listDisplaying) {
            a.list.style.display = "block";
            a.value.style.background = "#428fdc";
            a.value.style.color = "#fff";
            a.innerCtn.style.zIndex = this._config.ctnZindex;
            this.listDisplaying = true
        }
    }
    ;
    c.prototype.hide = function() {
        var a = this.els;
        if (this.listDisplaying) {
            a.list.style.display = "none";
            a.value.style.background = "#fff";
            a.value.style.color = "#000";
            a.innerCtn.style.zIndex = "0";
            this.listDisplaying = false
        }
    }
    ;
    c.prototype.set = function(a, b) {
        var d, e;
        if (b === true && !__.lang.isUndefined(this.values[a])) {
            e = a;
            a = this.values[a]
        } else
            e = this._config.items[a];
        if (__.lang.isUndefined(this._config.items[a]))
            this._error(this._cfg.txt.wrongValue);
        else {
            d = this.els.value;
            d.innerHTML = "";
            __.dom.addText(d,
                e);
            this.value = a;
            this.els.input.value = a;
            if (this._config.onChange) {
                this._config.onChange(a, e);
                __.event.fire(this, "change", [a, e])
            }
        }
    }
    ;
    c.prototype._createEls = function() {
        var a, b, d, e, f, i = this._config, l = this;
        e = __.ua;
        f = i.width;
        a = [2];
        if (e.ie > 6)
            a = [3];
        if (e.webkit)
            a = [1];
        b = [];
        d = this.values;
        __.each(i.items, function(j, k) {
            b.push({
                css: "padding:2px 14px 0 3px;width:" + (f - 21) + "px;background:#fff;",
                cls: l._cfg.cls.item,
                child: {
                    tag: "nobr",
                    css: "",
                    text: j
                }
            });
            d[j] = k
        }, true);
        __.dom.addEl({
            css: "height:" + i.height + "px;width:" + f + "px;cursor:pointer;font-size:" +
            this._config.fontsize + "px;position:relative;z-index:0;",
            cls: this._cfg.cls.container,
            child: [{
                css: "height:1px;font-size:1px;line-height:0;margin:0 1px;background:" + this._config.borderColor + ";width:" + (f - 2) + "px;overflow:hidden;float:left;display:inline;"
            }, {
                css: "background:" + this._config.bgColor + ";border:1px solid " + this._config.borderColor + ";border-width:0 1px;float:left;",
                child: [{
                    css: "height:1px;font-size:1px;line-height:0;border:1px solid #e3e2e2;border-width:0 1px;border-top-color:#0f0;width:" + (f -
                    4) + "px;float:left;"
                }, {
                    css: "height:" + (this._config.lineHeight + 3) + "px;float:left;padding-left:1px;width:" + (f - 3) + "px;",
                    child: [{
                        css: "padding:" + a[0] + "px 1px 0 3px;float:left;height:" + this._config.lineHeight + "px;line-height:" + this._config.lineHeight + "px;",
                        cls: this._cfg.cls.value,
                        text: this._config.items[this.value]
                    }, {
                        css: "width:11px;height:" + (this._config.lineHeight + 3) + "px;float:right;background:transparent url(" + i.bgSrc + ") no-repeat " + i.bgNormal + ";margin-right:1px;",
                        cls: this._cfg.cls.icon
                    }, {
                        css: "visibility:hidden;",
                        html: '<input type="hidden" value="' + this._config.defaultValue + '" name="' + this._config.name + '" class="' + this._cfg.cls.input + '"/>'
                    }]
                }, {
                    css: "height:1px;font-size:1px;line-height:0;border:1px solid #e3e2e2;border-width:0 1px;width:" + (f - 4) + "px;float:left;"
                }]
            }, {
                css: "height:1px;font-size:1px;line-height:0;margin:0 1px;background:" + this._config.borderColor + ";width:" + (f - 2) + "px;float:left;display:inline;overflow:hidden;"
            }, {
                cls: this._cfg.cls.list,
                css: "float:left;position:absolute;left:0px;top:" + (this._config.lineHeight +
                5) + "px;display:none;width:" + f + "px;z-index:" + this._config.zIndex,
                child: [{
                    css: "border:1px solid #D0CECE;/*border-bottom:0;*/background:#fff;padding:1px;text-align:left;",
                    child: {
                        tag: "ul",
                        css: "list-style:none;padding:0;margin:0;",
                        child: b
                    }
                }, {}]
            }]
        }, this.id)
    }
    ;
    c.prototype.disposeInternal = function() {
        c._super.disposeInternal.call(this);
        __.event.off(this.els.ctn, "mouseover", this._fns[0]);
        __.event.off(this.els.ctn, "mouseout", this._fns[1]);
        __.event.off(__.doc, "click", this._fns[2]);
        this._fns = null ;
        this.els.ctn =
            null ;
        this.els.innerCtn = null ;
        this.els.value = null ;
        this.els.icon = null ;
        this.els.list = null ;
        this.els = this.els.input = null
    }
});


__.BasicModule.register("fn-smartbox", "2.0", ["lang", "dom", "selector", "event", "cookie", "fn-table"], function() {
    var c;
    __.widget.SmartBox = function(a, b) {
        var d, e = c._cfg;
        b = b || {};
        this.status = e.status.READY;
        d = this._config = __.lang.clone(e.defInstCfg);
        __.each(b, function(f, i) {
            d[i] = f
        }, true);
        d.inputHint = d.inputHint || e.txt.inputHint;
        this.moreCls = e.cls.more + a;
        this._errQuery = this.zeroList = false;
        this.loadingQT = this.listQT = "";
        this.showCount = 0;
        this._listJustCreated = false;
        this.typeIpt = this.subIpt = this.queryIpt = this.form =
            null ;
        this.containerId = a;
        this.resultCtnId = a + e.resultCtnIdPostfix;
        this._createEls();
        this._initEls();
        this._initEvents();
        this._config.autoFocus && this.queryIpt.select()
    }
    ;
    __.inherits(__.widget.SmartBox, __.widget.Base);
    c = __.widget.SmartBox;
    c._cfg = {
        liIdPrefix: "du-sx-li~",
        selectIdPrefix: "du-sx-sel-",
        resultCtnIdPostfix: "-du-sx-result",
        pstockLink: "http://stockapp.finance.qq.com/pstock/",
        hintUrl: "http://smartbox.gtimg.cn/s3/?",
        formActionBase: "http://stock.finance.qq.com/cgi-bin/",
        txt: {
            stocksearch: "\u80a1\u7968\u67e5\u8be2",
            ALL: "\u5168\u90e8",
            GP: "\u6caa\u6df1",
            HK: "\u6e2f\u80a1",
            JJ: "\u57fa\u91d1",
            AS: "\u7f8e\u80a1",
            FT: "\u671f\u8d27",
            check: "\u67e5\u8be2",
            pstock: "\u6211\u7684\u81ea\u9009\u80a1",
            inputHint: "\u4ee3\u7801/\u540d\u79f0/\u62fc\u97f3",
            errHint: "\u60a8\u8f93\u5165\u7684\u67e5\u8be2\u8bcd\u6709\u8bef",
            emptyHint: "\u8bf7\u8f93\u5165\u67e5\u8be2\u6761\u4ef6\uff1a\u4ee3\u7801/\u540d\u79f0/\u62fc\u97f3",
            noResult: "\u672a\u627e\u5230\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c"
        },
        cls: {
            query: "du-sx-query",
            submit: "du-sx-submit",
            select: "du-sx-select",
            type: "du-sx-type",
            li: "du-sx-li",
            more: "du-sx-more-"
        },
        status: {
            READY: 0,
            INITED: 1,
            HIDDEN: 3,
            SHOWN: 4
        },
        typeEnum: ["ALL", "GP", "HK", "JJ", "AS", "FT"],
        typeMap: {
            ALL: "all",
            GP: "gp",
            HK: "hk",
            JJ: "jj",
            AS: "us",
            FT: "qh"
        },
        mktMap: {
            sh: "\u4e0a\u6d77",
            sz: "\u6df1\u5733",
            jj: "\u57fa\u91d1",
            hk: "\u6e2f\u80a1",
            us: "\u7f8e\u80a1",
            qh: "\u671f\u8d27"
        },
        mktNumMap: {
            jj: 0,
            sh: 1,
            sz: 51,
            hk: 100,
            us: 200,
            qh: 350
        },
        defInstCfg: {
            maxLine: 13,
            typeWait: 50,
            showType: true,
            defaultType: "ALL",
            showPLink: true,
            showTitle: true,
            directionUp: false,
            onclick: function(a) {
                if (a.length === 2)
                    this.onMstats(a[1]);
                else
                    __.global.open(__.fnTable.getPageUrl(a[1], a[2]) + "?pgv_ref=fi_smartbox&_ver=" + __.BasicModule.loadedMods["fn-smartbox"], this.useSelf ? "_self" : "_blank")
            },
            onsubmit: false,
            onsubmit2: false,
            zindex: 1,
            maxQuery: 10,
            showMarket: true,
            listXOffset: 0,
            listYOffset: 0,
            name: "",
            inputHint: "",
            matchRecent: false,
            autoSelect: false,
            adjustLimit: 2,
            showAll: true,
            sendToBoss: true,
            dataScope: null ,
            useSelf: false,
            autoFocus: false,
            preFill: false,
            blurColor: "#B4B3B3",
            onMstats: false,
            iframeMask: false
        }
    };
    c.legalQuery = __.lang.getReg("^[.,0-9a-zA-Z\\u4e00-\\u9fa5]+$");
    c.getRecentCode = function() {
        var a, b, d;
        if (__.lang.isUndefined(this._recentCookieCache)) {
            b = [];
            d = __.fnTable.mapNumMarket;
            a = (__.cookie.get("RECENT_CODE") + __.cookie.get("ASRECENT_CODE")).split("|");
            __.each(a, function(e) {
                if (e && b.length < 10) {
                    e = e.split("_");
                    if (e.length > 1 && !__.lang.isUndefined(d[e[1]]))
                        b.push(d[e[1]] +
                            e[0]);
                    else
                        e.length === 1 && b.push("jj" + e[0])
                }
            });
            this._recentCookieCache = b.join(",").toLowerCase()
        }
        return this._recentCookieCache
    }
    ;
    c.setHover = function(a) {
        if (this._lastHoverLi && this._lastHoverLi !== a)
            this._lastHoverLi.style.backgroundColor = "#fff";
        if (a && a.style)
            a.style.backgroundColor = "#deefff";
        this._lastHoverLi = a
    }
    ;
    c.prototype._getLine = function() {
        return {
            tag: "li",
            css: "padding:0;margin:4px 3px;float:left;_display:inline;background:#eaeaea;height:2px;line-height:2px;font-size:0;width:254px;"
        }
    }
    ;
    c.prototype._showList =
        function(a) {
            var b, d, e, f, i = [], l = "", j = "", k = a.split("~"), m = this.cache[a], n = this;
            if (this.listQT === a)
                __.lang.log("Draw cancelled for the same query.");
            else {
                this.listQT = a;
                k = k[0];
                if (this._config.directionUp) {
                    b = "push";
                    d = "unshift"
                } else {
                    b = "unshift";
                    d = "push"
                }
                if (this.resultList) {
                    this.resultList.innerHTML = "";
                    f = function(g, h) {
                        var o = k.toUpperCase()
                            , p = '<span style="color:#f45243;height:20px;line-height:20px;">' + o + "</span>";
                        g = g.toUpperCase();
                        return g = h && __.lang.endWith(g, o) ? g.substr(0, g.length - o.length) + p : g.replace(o,
                            p)
                    }
                    ;
                    this._config.onMstats && m[2] && __.each(m[2].split("^"), function(g) {
                        var h = {};
                        g = g.split("~");
                        h.isMstats = true;
                        h.id = g[0];
                        h.col0 = f(g[2]);
                        h.col2 = f(g[0]);
                        h.col1 = f(g[1]);
                        i.push(n._getLiObj(h))
                    });
                    if (__.lang.isUndefined(m[0]))
                        m[0] = "N";
                    __.each(m[0].split("^"), function(g) {
                        if (g)
                            j += g + "~Y^"
                    });
                    j += m[1];
                    j = j.split("^");
                    __.each(j, function(g) {
                        var h;
                        g = g.split("~");
                        h = {};
                        if (!(!g || g.length < 4))
                            if (!(i.length >= n._config.maxLine)) {
                                h.code = g[1].toUpperCase();
                                h.numType = c._cfg.mktNumMap[g[0]];
                                h.market = c._cfg.mktMap[g[0]];
                                if (g[4] ===
                                    "QH-IF") {
                                    h.market = "\u80a1\u671f";
                                    h.numType = 300
                                } else if (g[4] === "ZQ")
                                    h.market = "\u503a\u5238";
                                h.category = g[4];
                                h.name = g[2];
                                switch (g[4]) {
                                    case "FJ":
                                    case "ETF":
                                        h.market = "\u57fa\u91d1"
                                }
                                if (h.numType === 200) {
                                    e = g[1].indexOf(".");
                                    h.col0 = e > 0 ? g[1].substr(0, e) : g[1]
                                } else
                                    h.col0 = g[1];
                                h.col0 = f(h.col0, true);
                                h.col1 = f(g[2]);
                                h.col2 = f(g[3]);
                                if (h = n._getLiObj(h)) {
                                    if (l !== g[7] && i.length > 0)
                                        i[d](n._getLine());
                                    l = g[7];
                                    if (g[0] + "~" + g[3] === "00700~100")
                                        i[b](h);
                                    else
                                        i[d](h)
                                }
                            }
                    });
                    if (i.length > 0) {
                        if (this._config.showMarket && this._config.showAll)
                            i[d]({
                                tag: "li",
                                css: "padding:0;float:left;_display:inline;text-align:right;width:250px;height:20px;line-height:20px;",
                                child: {
                                    tag: "b",
                                    text: "\u67e5\u770b\u5168\u90e8",
                                    cls: this.moreCls,
                                    css: "color:blue;text-decoration:underline;font-weight:normal;cursor:pointer;"
                                }
                            });
                        if (__.ua.ie === 6)
                            __.dom.f(this.resultCtnId).style.paddingBottom = i.length === 1 ? "0" : "3px";
                        __.dom.addEl(i, this.resultList);
                        this.zeroList = false;
                        c.setHover(this._config.directionUp ? this.resultList.lastChild : this.resultList.firstChild);
                        this._listJustCreated = true;
                        this.show(true)
                    } else {
                        this.zeroList = true;
                        this._showError(c._cfg.txt.noResult.replace("##query##", k))
                    }
                }
            }
        }
    ;
    c.prototype._getLiObj =
        function(a) {
            var b = false, d, e, f;
            f = this._config.showMarket;
            if (a.numType === 200 && a.col2 === "*") {
                d = f ? [246, 54, 142, 5, 45, 0] : [138, 44, 89, 0, 0, 0];
                e = false
            } else if (a.isMstats)
                d = [246, 54, 75, 5, 60, 0];
            else {
                d = f ? [246, 54, 75, 5, 60, 5] : [138, 44, 48, 5, 36, 0];
                e = {
                    tag: "span",
                    css: "float:left;width:" + d[4] + "px;margin-right:" + d[5] + "px;height:20px;line-height:20px;overflow:hidden;",
                    html: a.col2
                }
            }
            if (f)
                if (a.isMstats) {
                    e = {
                        tag: "span",
                        css: "float:left;width:" + d[4] + "px;margin-right:" + d[5] + "px;height:20px;line-height:20px;overflow:hidden;",
                        html: a.col2
                    };
                    b = {
                        tag: "span"
                    }
                } else {
                    if (a.numType === 1)
                        a.code.substr(0, 1) !== "9" && a.code.substr(0, 2);
                    else
                        a.numType === 51 && a.code.substr(0, 1) !== "2" && a.code.substr(0, 2);
                    b = {
                        tag: "span",
                        css: "float:right;width:40px;text-align:right;color:#a9a9a9;height:20px;line-height:20px;overflow:hidden;",
                        text: a.market
                    }
                }
            return {
                tag: "li",
                css: "padding:0;margin:0 2px;cursor:pointer;float:left;_display:inline;_margin:0 1px;",
                id: c._cfg.liIdPrefix + (a.isMstats ? a.id : a.code + "~" + a.numType + "~" + (a.category || "") + "~" + a.name),
                cls: c._cfg.cls.li,
                child: {
                    css: "margin:0 5px;float:left;_display:inline;width:" +
                    d[0] + "px;height:20px;line-height:20px;overflow:hidden;",
                    child: {
                        tag: "nobr",
                        child: [{
                            tag: "span",
                            css: "float:left;width:" + d[1] + "px;margin-right:5px;height:20px;line-height:20px;overflow:hidden;",
                            html: a.col0
                        }, {
                            tag: "span",
                            css: "float:left;font-family:Arial;margin-right:" + d[3] + "px;height:20px;line-height:22px;_line-height:23px;overflow:hidden;width:" + d[2] + "px;",
                            html: a.col1
                        }, e, b]
                    }
                }
            }
        }
    ;
    c.prototype._getListCtn = function(a) {
        var b, d;
        b = __.dom.f(this.resultCtnId);
        d = this._config.showMarket ? 260 : 152;
        if (b) {
            if (a) {
                a = this.queryIpt;
                b.style.left = __.dom.getPosition(a, "offsetLeft") + this._config.listXOffset + "px";
                b.style.top = __.dom.getPosition(a, "offsetTop") + a.offsetHeight + this._config.listYOffset + 1 + "px"
            }
        } else {
            b = {
                id: this.resultCtnId,
                css: "width:" + d + "px;overflow:hidden;text-align:left;background:#FFF;position:absolute;font-size:12px;visibility:hidden;z-index:" + this._config.zindex,
                child: [{
                    tag: "ul",
                    css: "font-family:Arial;margin:0;padding:0;border:1px solid #9c9c9c;padding:3px 0;list-style:none;overflow:hidden;_zoom:1;"
                }]
            };
            if (__.ua.ie ===
                6 || this._config.iframeMask)
                b.child.push({
                    tag: "iframe",
                    css: "width:290px;height:3000px;filter:alpha(opacity=0);position:absolute;top:0;left:-1px;z-index:-1;",
                    frameBorder: "0"
                });
            b = __.dom.addEl(b);
            __.dom.insertBefore(b, __.doc.body.firstChild);
            this.resultList = b.getElementsByTagName("ul")[0];
            a = this.queryIpt;
            b.style.left = __.dom.getPosition(a, "offsetLeft") + this._config.listXOffset + "px";
            b.style.top = __.dom.getPosition(a, "offsetTop") + a.offsetHeight + this._config.listYOffset + 1 + "px"
        }
        return b
    }
    ;
    c.prototype._sendRequest =
        function() {
            var a, b, d, e, f = this.queryIpt, i = this.typeIpt, l = this.cache, j = this;
            b = __.lang.trim(f.value).toLowerCase();
            d = i.value;
            e = b + "~" + d;
            if (this.listQT === e)
                __.lang.log("same query:" + e);
            else if (this.loadingQT !== e)
                if (b === "") {
                    this.listQT = "";
                    this.hide()
                } else if (c.legalQuery.test(b))
                    if (l[e])
                        this._showList(e);
                    else {
                        a = c._cfg.hintUrl + "q=" + encodeURIComponent(b) + "&t=" + encodeURIComponent(c._cfg.typeMap[d]);
                        if (this._config.onMstats)
                            a += "&c=1";
                        if (this._config.matchRecent)
                            a += "&c=" + encodeURIComponent(c.getRecentCode());
                        setTimeout(function() {
                            var k = j._config.dataScope || __.global;
                            if (__.lang.trim(f.value).toLowerCase() === b && j.typeIpt.value === d) {
                                __.lang.log("begin load query:" + b);
                                j.loadingQT = e;
                                __.load(a, function() {
                                    __.lang.log("data loaded for " + b + "~" + d);
                                    j.loadingQT = "";
                                    if (__.lang.trim(f.value).toLowerCase() === b && j.typeIpt.value === d) {
                                        l[e] = [k.v_hint_R, k.v_hint];
                                        if (j._config.onMstats)
                                            l[e].push(k.v_cate_hint || "");
                                        j._showList(e);
                                        __.lang.log("list drawed for " + j.listQT);
                                        k.v_cate_hint = undefined;
                                        k.v_hint_R = undefined;
                                        k.v_hint =
                                            undefined
                                    }
                                }, {
                                    charset: "gbk",
                                    cache: true,
                                    doc: k.document
                                })
                            }
                        }, this._config.typeWait)
                    }
                else {
                    this.listQT = e;
                    this._errQuery = true;
                    this._showError()
                }
        }
    ;
    c.prototype.cache = {};
    c.prototype._createEls = function() {
        var a, b, d = __.dom.f(this.containerId), e = false, f = false, i = false, l = this._config.preFill || this._config.inputHint;
        if (b = this._config.attach) {
            if (!b.form.ZHENGQUANDM) {
                if (__.ua.ie)
                    try {
                        a = __.doc.createElement('<input name="ZHENGQUANDM" type="hidden">')
                    } catch (j) {
                        a = false
                    }
                if (!a) {
                    a = __.doc.createElement("input");
                    a.name = "ZHENGQUANDM";
                    a.type = "hidden"
                }
                b.form.appendChild(a)
            }
        } else {
            if (this._config.showType)
                e = {
                    css: "margin-left:10px;margin-right:2px;_margin-top:1px;float:left;",
                    id: c._cfg.selectIdPrefix + this.containerId
                };
            if (this._config.showPLink)
                f = {
                    css: "float:left;height:20px;line-height:23px;",
                    child: {
                        tag: "a",
                        text: c._cfg.txt.pstock,
                        href: c._cfg.pstockLink,
                        target: "_blank"
                    }
                };
            if (this._config.showTitle)
                i = {
                    text: c._cfg.txt.stocksearch,
                    css: "float:left;height:20px;line-height:23px;"
                };
            __.dom.addEl({
                tag: "form",
                target: "_blank",
                css: "float:left;z-index:" +
                this._config.zindex,
                method: "post",
                child: {
                    tag: "ul",
                    css: "list-style:none;margin:0;padding:0;font-size:12px;font-family:Arial;color:#333333;",
                    child: [i, e, {
                        css: "float:left",
                        html: '<input type="text" style="width:96px;height:16px;padding:2px 0 0 4px;line-height:16px;border:1px solid #D0CECE;vertical-align:top;margin-right:5px;font-size:12px;color:' + this._config.blurColor + ";font-family:Arial;" + (this._config.showType ? "" : "margin-left:5px;") + '" value="' + l + '" class="' + c._cfg.cls.query + '" name="cl" autocomplete="off" maxlength="' +
                        this._config.maxQuery + '" />'
                    }, {
                        css: "float:left;margin-right:15px;display:inline;padding-top:1px;_padding-top:2px;",
                        child: [{
                            tag: "input",
                            type: "submit",
                            css: "width:47px;border:0;cursor:pointer;background:transparent url(http://mat1.gtimg.com/finance/stock/images/smartbox-btn2.png) no-repeat scroll 0px 0px;vertical-align:top;font-size:12px;" + (__.ua.ie ? "height:19px;padding:3px 5px 0;" : "height:19px;padding:0 5px;"),
                            value: c._cfg.txt.check,
                            cls: c._cfg.cls.submit
                        }, {
                            tag: "span",
                            html: '<input type="hidden" name="ZHENGQUANDM"/>' +
                            (this._config.showType ? "" : '<input type="hidden" value="" name="qc_type" class="' + c._cfg.cls.type + '" />')
                        }]
                    }, f]
                }
            }, d);
            d.style.height = "21px"
        }
    }
    ;
    c.prototype._hlResize = function() {
        var a = this.queryIpt
            , b = this._getListCtn();
        b.style.left = __.dom.getPosition(a, "offsetLeft") + this._config.listXOffset + "px";
        b.style.top = __.dom.getPosition(a, "offsetTop") + a.offsetHeight + 1 + "px";
        this.hide()
    }
    ;
    c.prototype._hlScroll = function(a) {
        var b = __.ua;
        (b.gecko || b.webkit) && a.target !== __.doc || this.hide()
    }
    ;
    c.prototype._hlFocus = function(a) {
        a =
            a.srcElement || a.target;
        if (a.value === this._config.inputHint)
            a.value = "";
        a.style.color = "#333333";
        this._config.autoSelect && a.select();
        if (this.status === c._cfg.status.HIDDEN && (this.isQueryChanged() || !this._config.autoSelect))
            this.show()
    }
    ;
    c.prototype._hlBlur = function(a) {
        a = a.srcElement || a.target;
        if (a.value === "") {
            a.style.color = this._config.blurColor;
            a.value = this._config.inputHint
        }
    }
    ;
    c.prototype._hlKeyup = function(a) {
        if (!__.lang.inArray(a.keyCode, [13, 27, 38, 40])) {
            __.lang.log("user key up : " + this.queryIpt.value);
            this._errQuery = false;
            this._sendRequest()
        }
    }
    ;
    c.prototype._hlKeydown = function(a) {
        var b;
        b = this.queryIpt;
        if (this.status === c._cfg.status.SHOWN && !this._errQuery)
            switch (a.keyCode) {
                case 38:
                    if (this.zeroList)
                        break;
                    if (!this.resultList)
                        break;
                    b = c._lastHoverLi && c._lastHoverLi.previousSibling ? c._lastHoverLi.previousSibling : this.resultList.lastChild;
                    __.dom.hasClass(b, c._cfg.cls.li) || (b = b.previousSibling ? b.previousSibling : this.resultList.lastChild);
                    c.setHover(b);
                    __.event.stopEvent(a);
                    break;
                case 40:
                    if (this.zeroList)
                        break;
                    if (!this.resultList)
                        break;
                    b = c._lastHoverLi && c._lastHoverLi.nextSibling ? c._lastHoverLi.nextSibling : this.resultList.firstChild;
                    __.dom.hasClass(b, c._cfg.cls.li) || (b = b.nextSibling ? b.nextSibling : this.resultList.firstChild);
                    c.setHover(b);
                    __.event.stopEvent(a);
                    break;
                case 27:
                    this.hide();
                    break;
                case 13:
                    this._enterPressed = true
            }
        else if (this.status === c._cfg.status.HIDDEN)
            if (a.keyCode === 38 || a.keyCode === 40 || b.value.length === 1 && b.value.charCodeAt(0) === a.keyCode || a.ctrlKey && a.keyCode === 86)
                this.show()
    }
    ;
    c.prototype._hlMouseover =
        function(a) {
            for (a = a.target || a.srcElement; a && a !== __.doc.documentElement && a.className !== c._cfg.cls.li; )
                a = a.parentNode;
            a.className === c._cfg.cls.li && c.setHover(a)
        }
    ;
    c.prototype._hlDocClick = function(a) {
        a = a.target || a.srcElement;
        if (a !== this.subIpt)
            if (a === this.queryIpt) {
                this.status === c._cfg.status.SHOWN && !this._errQuery && this._config.autoSelect && !this._listJustCreated && this.hide();
                this._config.autoSelect && this.queryIpt.select();
                this._listJustCreated = false
            } else if (a.className === this.moreCls)
                this._setForm();
            else if (this.status === c._cfg.status.SHOWN) {
                for (; a && a !== __.doc.documentElement && a.className !== c._cfg.cls.li; )
                    a = a.parentNode;
                if (a && a.className === c._cfg.cls.li) {
                    a = a.id.split("~");
                    this._onSelect(a, 1)
                }
                this.hide()
            }
    }
    ;
    c.prototype.getResult = function() {
        if (this.zeroList)
            return false;
        if (this._resultQT == __.lang.trim(this.queryIpt.value).toLowerCase() + "~" + this.typeIpt.value)
            return this._resultIds;
        if (!this.resultList)
            return false;
        var a = this._hasMatchRow()
            , b = this._config.directionUp ? this.resultList.lastChild : this.resultList.firstChild;
        if (!a && b)
            a = b.id.split("~");
        return a
    }
    ;
    c.prototype._hlSubmit = function(a) {
        var b, d, e = this, f = this._enterPressed ? 0 : 2;
        this._enterPressed = false;
        if (this._config.onsubmit2)
            this._config.onsubmit2(a, c._lastHoverLi, this);
        else {
            if (!this.zeroList && !this.isQueryChanged()) {
                if (!this.resultList) {
                    __.event.preventDefault(a);
                    return false
                }
                d = this._config.directionUp ? this.resultList.lastChild : this.resultList.firstChild;
                if (f === 0) {
                    if (this.status === c._cfg.status.SHOWN)
                        if (c._lastHoverLi || d) {
                            b = (c._lastHoverLi || d).id.split("~");
                            this._onSelect(b, f);
                            this.hide()
                        }
                } else {
                    (b = this._hasMatchRow()) || (b = d.id.split("~"));
                    this._onSelect(b, f);
                    this.hide()
                }
            } else if (this._checkInput())
                if (this.isQueryChanged()) {
                    __.lang.log("b4show redefined");
                    this.b4Show = function() {
                        var i = e._config.directionUp ? e.resultList.lastChild : e.resultList.firstChild;
                        if (b = e._hasMatchRow()) {
                            e._onSelect(b, f);
                            e.hide()
                        } else if (e.zeroList)
                            if (e._config.onsubmit)
                                e._config.onsubmit(e.queryIpt.value, e.typeIpt.value, a);
                            else
                                e._setForm(a);
                        else {
                            b = i.id.split("~");
                            e._onSelect(b, f);
                            e.hide()
                        }
                        return e.b4Show = false
                    }
                } else {
                    if (this._config.onsubmit)
                        this._config.onsubmit(this.queryIpt.value, this.typeIpt.value, a);
                    else
                        this._setForm(a);
                    return
                }
            __.event.preventDefault(a)
        }
    }
    ;
    c.prototype.hide = function() {
        if (this.status === c._cfg.status.SHOWN) {
            __.lang.log("to hide");
            var a = this._getListCtn();
            a.style.visibility = "hidden";
            a.style.marginLeft = "-10000px";
            a = a.getElementsByTagName("iframe");
            a.length && (a[0].style.display = "none");
            c.setHover(null );
            this.status = c._cfg.status.HIDDEN
        }
    }
    ;
    c.prototype.show = function(a,
                                b) {
        if (a || !this.isQueryChanged()) {
            b = typeof b === "boolean" ? b : this.showCount++ < this._config.adjustLimit;
            if (!this.b4Show || this.b4Show()) {
                var d = this._getListCtn(b);
                d.style.visibility = "visible";
                d.style.marginLeft = "";
                d = d.getElementsByTagName("iframe");
                d.length && (d[0].style.display = "block");
                this.status = c._cfg.status.SHOWN
            }
        } else {
            __.lang.log("send from show");
            this._sendRequest()
        }
    }
    ;
    c.prototype.isQueryChanged = function() {
        return this.listQT !== __.lang.trim(this.queryIpt.value).toLowerCase() + "~" + this.typeIpt.value
    }
    ;
    c.prototype._onSelect = function(a, b) {
        var d;
        this._resultQT = this.listQT;
        this._resultIds = a;
        if (this._config.sendToBoss) {
            d = ["http://btrace.qq.com/collect?sIp=&iQQ=", __.cookie.get("o_cookie") || "0", "&sBiz=finance.stock.smartbox&sOp=browse&iSta=0&iTy=179&iFlow=", new Date % 1E8, "&sInput=", encodeURIComponent(this.queryIpt.value), "&sSubmit=", b === 0 ? "enter" : b === 1 ? "click" : "button", "&sMarket=", encodeURIComponent(this.typeIpt.value.toLowerCase()), "&sCode=", encodeURIComponent(__.fnTable.mapNumMarket[a[2]] + a[1]), "&sName=",
                encodeURIComponent(a[4]), "&sRefer=", encodeURIComponent((location.host + location.pathname).substr(0, 200))].join("");
            this._bossImg = new Image;
            this._bossImg.src = d
        }
        this._config.onclick(a)
    }
    ;
    c.prototype._initEls = function() {
        var a, b, d;
        b = c._cfg.cls;
        var e = "#" + this.containerId + " .";
        if (this._config.attach) {
            b = this._config.attach;
            this.form = b.form;
            this.queryIpt = b.query;
            this.subIpt = b.submit;
            this.typeIpt = b.type;
            if (this._config.preFill)
                this.queryIpt.value = this._config.preFill;
            this.typeIpt.value = this._config.defaultType
        } else {
            this.queryIpt =
                __.dom.f(e + b.query);
            this.subIpt = __.dom.f(e + b.submit);
            this.form = __.dom.f("#" + this.containerId + " form");
            if (this._config.showType) {
                a = {};
                d = c._cfg.txt;
                __.each(c._cfg.typeEnum, function(f) {
                    a[f] = d[f]
                });
                this.typeIpt = new __.widget.Select(c._cfg.selectIdPrefix + this.containerId,{
                    items: a,
                    defaultValue: this._config.defaultType,
                    fontsize: 12,
                    name: "qc_type"
                })
            } else {
                this.typeIpt = __.dom.f(e + b.type);
                this.typeIpt.value = this._config.defaultType
            }
        }
        this.queryIpt.onfocus = null
    }
    ;
    c.prototype._initEvents = function() {
        var a = this.queryIpt
            ,
            b = __.event
            , d = b.bind;
        d = [d(this._hlFocus, this), d(this._hlBlur, this), d(this._hlKeyup, this), d(this._hlKeydown, this), d(this._hlMouseover, this), d(this._hlDocClick, this), d(this._hlSubmit, this), d(this._hlResize, this), d(this._hlScroll, this)];
        b.on(a, "focus", d[0]);
        b.on(a, "blur", d[1]);
        b.on(a, "keyup", d[2]);
        b.on(a, "keydown", d[3]);
        b.on(this._getListCtn(), "mouseover", d[4]);
        b.on(__.doc, "click", d[5]);
        b.on(this.form, "submit", d[6]);
        b.on(__.global, "resize", d[7], true);
        b.on(__.global, "scroll", d[8], true);
        b.on(this.typeIpt,
            "change", d[2]);
        this._fns = d
    }
    ;
    c.prototype._hasMatchRow = function() {
        if (!this.resultList)
            return false;
        var a, b = this.queryIpt.value, d = this.resultList.childNodes, e = false;
        if (!this.zeroList) {
            a = d.length === 1 ? 0 : __.lang.find(d, function(f) {
                if (!f.id)
                    return false;
                f = (f = f.id.split("~")[1]) && f.split(".")[0];
                return f === b
            });
            if (a !== -1)
                e = d[a].id.split("~")
        }
        return e
    }
    ;
    c.prototype._checkInput = function() {
        var a = c._cfg.txt.errHint
            , b = this.queryIpt.value;
        b = b.replace(__.lang.getReg("\\s", "gi"), "");
        if (b === "" || b === this._config.inputHint)
            a =
                c._cfg.txt.emptyHint;
        else if (__.lang.getReg("^[\\*\\/0-9a-zA-Z\\u4e00-\\u9fa5]+$").test(b) && !__.lang.getReg("[\\\\\\/<>#\\$&]").test(b))
            a = true;
        a !== true && this._showError(a);
        return a === true
    }
    ;
    c.prototype._showError = function(a) {
        if (this.resultList) {
            a = a || c._cfg.txt.errHint;
            this.resultList.innerHTML = "";
            __.dom.addEl({
                tag: "li",
                css: "padding:5px 0 5px 7px;line-height:15px;",
                html: a
            }, this.resultList);
            this.show(true)
        }
    }
    ;
    c.prototype._setForm = function(a) {
        a && __.event.stopEvent(a);
        a = "http://stock.finance.qq.com/sstock/search.php?c=utf8&t=all&q=" +
            encodeURIComponent(this.queryIpt.value.split(".")[0]);
        __.global.open(a, "_blank")
    }
    ;
    c.prototype.disposeInternal = function() {
        var a = this.queryIpt
            , b = this._fns
            , d = __.event;
        c._super.disposeInternal.call(this);
        d.off(a, "focus", b[0]);
        d.off(a, "blur", b[1]);
        d.off(a, "keyup", b[2]);
        d.off(a, "keydown", b[3]);
        d.off(this._getListCtn(), "mouseover", b[4]);
        d.off(__.doc, "click", b[5]);
        d.off(this.form, "submit", b[6]);
        d.off(__.global, "resize", b[7], true);
        d.off(__.global, "scroll", b[8], true);
        d.off(this.typeIpt, "change", b[2]);
        this.typeIpt =
            this.subIpt = this.queryIpt = this.form = this._fns = null ;
        a = this._config;
        a.dataScope = null ;
        a.onclick = null ;
        a.onsubmit = null ;
        a.onsubmit2 = null
    }
});
/*  |xGv00|ce3bb1eeb5d845b9a8f52720115f12ab */